<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/9/11
  Time: 17:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/include.jsp" %>
<html>
<head>
    <title>Title</title>
    <script src="components/multiselect/multiple-select.js"></script>

    <link href="components/multiselect/multiple-select.css?2017" rel="stylesheet">
    <style>
        .form-control {
            margin: 10px 0
        }

    </style>


    <script>

        $(function () {
            $('#status').change(function () {
                console.log($(this).val());
            }).multipleSelect({
                width: '120px',
                placeholder: '状态'
            });
            $('#feedbackCity').change(function () {
                console.log($(this).val());
            }).multipleSelect({
                width: '120px',
                placeholder: '反馈城市'
            });
            $('#title').change(function () {
                console.log($(this).val());
            }).multipleSelect({
                width: '120px',
                placeholder: '标题'
            });

            laydate.render({
                elem: '#beginTime'
                , range: true
            });
            laydate.render({
                elem: '#finishBeginTime'
                , range: true
            });
        });
    </script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox ">
                <div class="ibox-content">

                    <div class="jqGrid_wrapper">
                        <div class="ui-jqgrid " id="gbox_table_list_2" dir="ltr">
                            <div class="ui-jqgrid-view table-responsive" style="height: 100%" role="grid"
                                 id="gview_table_list_2"
                            >


                                <form role="form" class="form-inline" style="margin-bottom: 10px" id="searchForm"
                                      method="post" action="taskBugList.html">

                                    <input type="hidden" id="myDem" value="${myDem}">
                                    <div class="form-group" style="width: 100%">
                                        <select id="status" multiple="multiple"
                                                name="conditions['status']"
                                                required="" aria-required="true">
                                            <option value="1"
                                                    <c:if test="${fn:indexOf(pages.conditions.status,',1,') >= 0}">selected</c:if>>
                                                待审核
                                            </option>
                                            <option value="2"
                                                    <c:if test="${fn:indexOf(pages.conditions.status,',2,') >= 0}">selected</c:if>>
                                                已审核
                                            </option>
                                            <option value="3"
                                                    <c:if test="${fn:indexOf(pages.conditions.status,',3,') >= 0}">selected</c:if>>
                                                处理中
                                            </option>
                                            <option value="4"
                                                    <c:if test="${fn:indexOf(pages.conditions.status,',4,') >= 0}">selected</c:if>>
                                                已处理
                                            </option>
                                            <option value="6"
                                                    <c:if test="${fn:indexOf(pages.conditions.status,',6,') >= 0}">selected</c:if>>
                                                已驳回
                                            </option>
                                            <option value="7"
                                                    <c:if test="${fn:indexOf(pages.conditions.status,',7,') >= 0}">selected</c:if>>
                                                已暂停
                                            </option>
                                        </select>
                                        &nbsp;&nbsp;
                                        <input readonly id="finishBeginTime" placeholder="处理完成时间"
                                               name="conditions['finishBeginTime']" size="20"
                                               value="${pages.conditions.finishBeginTime}"
                                               type="text"
                                               class="form-control">
                                        <input type="hidden" name="conditions['finishEndTime']"
                                               value="${pages.conditions.finishEndTime}" id="finishEndTime">
                                        &nbsp;&nbsp;
                                        <select id="priority" name="conditions['priority']" class="form-control"
                                        >

                                            <option value="0">优先级</option>
                                            <option
                                                    <c:if test="${pages.conditions.priority == 1}">selected</c:if>
                                                    value="1">一级
                                            </option>
                                            <option
                                                    <c:if test="${pages.conditions.priority == 2}">selected</c:if>
                                                    value="2">二级
                                            </option>
                                            <option
                                                    <c:if test="${pages.conditions.priority == 3}">selected</c:if>
                                                    value="3">三级
                                            </option>
                                            <option
                                                    <c:if test="${pages.conditions.priority == 4}">selected</c:if>
                                                    value="4">四级
                                            </option>
                                            <option
                                                    <c:if test="${pages.conditions.priority == 5}">selected</c:if>
                                                    value="5">五级
                                            </option>
                                        </select>&nbsp;&nbsp;&nbsp;

                                        <select id="demandProduct" name="conditions['demandProduct']"
                                                class="form-control"
                                                required="" aria-required="true">
                                            <option value="0"
                                                    <c:if test="${pages.conditions.demandProduct == 0}">selected</c:if>>
                                                问题产品
                                            </option>
                                            <c:forEach items="${productList}" var="product">
                                                <option
                                                        <c:if test="${pages.conditions.demandProduct == product.id}">selected</c:if>
                                                        value="${product.id}">${product.product_name}</option>
                                            </c:forEach>
                                        </select>
                                        &nbsp;&nbsp;
                                        <input name="conditions['demId']" id="demId"
                                               placeholder="编号"
                                               type="text" size="8" value="${pages.conditions.demId}"
                                               class="form-control">&nbsp;&nbsp;
                                        &nbsp;&nbsp;
                                        <input name="conditions['programmer']" id="joinName" placeholder="开发人员"
                                               type="text" size="8" value="${pages.conditions.programmer}"
                                               class="form-control">&nbsp;&nbsp;&nbsp;

                                        <button type="button" onclick="queryDemand()"
                                                class="btn btn-primary">搜索
                                        </button>
                                        &nbsp;&nbsp;&nbsp;<input type="button" onclick="clearForms()" id="resetBut"
                                                                 value="重置" class="btn btn-reset">


                                        <div style="float: right;margin-right: 15px;margin-top: 25px">
                                            总记录：${pages.totalRecords}</div>
                                    </div>

                                </form>


                                <div class="ui-jqgrid-bdiv">
                                    <div style="position:relative;">
                                        <div></div>
                                        <table id="cusTable"
                                               class="ui-jqgrid-btable ui-common-table table table-bordered"
                                        >
                                            <tbody>
                                            <tr role="row" style="background: #F5F5F5;">

                                                <td>编号
                                                </td>
                                                <td>标题
                                                </td>
                                                <td>描述
                                                </td>
                                                <td>录入时间
                                                </td>
                                                <td>
                                                    状态
                                                </td>
                                                <td>责任人
                                                </td>
                                                <td>开发人
                                                </td>
                                                <td>预计时间
                                                <td>对应需求</td>
                                                <%--<td>操作--%>
                                                <%--</td>--%>
                                            </tr>


                                            <c:forEach items="${pages.pageDatas}" var="demand">
                                                <tr role="row" tabindex="-1" id="${demand.id}"
                                                    statusText="${demand.status_text}"
                                                    class="jqgrow ui-row-ltr">
                                                    <td>
                                                            ${demand.id}
                                                    </td>
                                                    <td>
                                                            ${demand.title}
                                                    </td>
                                                    <td>
                                                            ${fn:length(demand.detail) > 20 ? fn:substring(demand.detail,0,20) : demand.detail}

                                                    </td>

                                                    <td>
                                                        <fmt:parseDate value="${demand.create_time}"
                                                                       pattern="yyyy-MM-dd"
                                                                       var="receiveDate"></fmt:parseDate>
                                                        <fmt:formatDate value="${receiveDate}"
                                                                        pattern="yyyy-MM-dd"></fmt:formatDate>

                                                    </td>


                                                    <td>
                                                        <c:if test="${demand.is_suspend == 2}">已暂停</c:if>
                                                        <c:if test="${demand.is_suspend != 2}">
                                                            <c:if test="${demand.status_text == '已处理'}">
                                                                <font color="#20b2aa">${demand.status_text}</font>
                                                            </c:if>
                                                            <c:if test="${demand.status_text != '已处理'}">
                                                                ${demand.status_text}
                                                            </c:if>
                                                        </c:if>

                                                    </td>
                                                    <td>

                                                        <c:if test="${demand.status == 7}">总监</c:if>
                                                        <c:if test="${demand.status != 7 && demand.demandType!=3 }">${demand.current_principal}</c:if>
                                                        <c:if test="${demand.demandType == 3}">${demand.create_name}</c:if>
                                                    </td>
                                                    <td>
                                                            ${demand.programmer}
                                                    </td>

                                                    <td>
                                                        <fmt:parseDate value="${demand.antipate_finish_time}"
                                                                       pattern="yyyy-MM-dd"
                                                                       var="receiveDate"></fmt:parseDate>
                                                        <fmt:formatDate value="${receiveDate}"
                                                                        pattern="yyyy-MM-dd"></fmt:formatDate>

                                                    </td>

                                                    <td>
                                                        <a id="demSearchBtn" demId="${demand.demandId}"
                                                           title="查看" statusText="${demand.status_text}"
                                                            type="button">编号-${demand.demandId}
                                                        </a>

                                                    </td>
                                                    <%--<td>--%>
                                                        <%--<a id="searchBtn" demId="${demand.id}"--%>
                                                           <%--title="查看" statusText="${demand.status_text}"--%>
                                                           <%--demandType="${demand.demandType}"--%>
                                                           <%--class="handleicon" type="button"><i--%>
                                                                <%--class="fa fa-search"></i>--%>
                                                        <%--</a>--%>
                                                    <%--</td>--%>
                                                </tr>

                                            </c:forEach>


                                            </tbody>
                                        </table>
                                        <c:if test="${pages.totalPages>1 }">
                                            <page:pager pageSize="${pages.pageSize}" currPage="${pages.currPage}"
                                                        totalRecords="${pages.totalRecords}"
                                                        url="${pageContext.request.contextPath}/${action}?conditions['demandProduct']=${pages.conditions.demandProduct }
&conditions['createName']=${pages.conditions.createName }&conditions['status']=${pages.conditions.status }&conditions['beginTime']=${pages.conditions.beginTime1 }&conditions['joinName']=${pages.conditions.joinName }&conditions['currentPrincipal']=${pages.conditions.currentPrincipal }&conditions
['detail']=${pages.conditions.detail }&conditions['demandType']=${pages.conditions.demandType }&conditions['isSuspend']=${pages.conditions.isSuspend }&conditions
['programmer']=${pages.conditions.programmer }&conditions['feedbackName']=${pages.conditions.feedbackName }&conditions['title']=${pages.conditions.title }&conditions['finishBeginTime']=${pages.conditions.finishBeginTime1 }&conditions['finishEndTime']=${pages.conditions.finishEndTime }&conditions['endTime']=${pages.conditions.endTime }&conditions['demId']=${pages.conditions.demId }&bugType=${bugType}&conditions['priority']=${pages.conditions.priority }"/>

                                        </c:if>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</body>

<script>
    //enter搜索
    $('body').bind('keypress', function (event) {
        if (event.keyCode == "13") {
            queryDemand()
        }
    })
    function queryDemand() {
        var demandType = $("#demandType").val();
        var myDem = $("#myDem").val();

        $("#searchForm").attr("action", "taskBugList.html?myDem=" + myDem);
        demandType = "BUG"

        var finishBeginTime = $("#finishBeginTime").val();

        if ("" != finishBeginTime) {
            $("#finishEndTime").val(finishBeginTime.substring(13));
            $("#finishBeginTime").val(finishBeginTime.substring(0, 10));
        }
        $("#searchForm").submit();
    }

    $(function () {

        //单击tr弹出详细页面
        $("[id=searchBtn]").click(function () {

            var demandType = $(this).attr('demandType');

            var content = 'bugDetail.html?bugId=';
            demandType = "BUG"

            var title = demandType + "-" + $(this).attr('statusText');
            index = layer.open({
                type: 2,
                title: title,
                skin: 'ilayui-layer-rm', //加上边框
                area: ['90%', '90%'], //宽高
                content: content + $(this).attr('demId'),
//                end: function () {
//                    location.reload();
//                }
            });
        });


        //单击tr弹出详细页面
        $("[id=demSearchBtn]").click(function () {

            var content = 'demandDetail.html?demandId=';


            var title = "BUG-对应需求";
            index = layer.open({
                type: 2,
                title: title,
                skin: 'ilayui-layer-rm', //加上边框
                area: ['90%', '90%'], //宽高
                content: content + $(this).attr('demId'),
//                end: function () {
//                    location.reload();
//                }
            });
        });


        //双击tr弹出详细页面
        $("#cusTable tr td").dblclick(function () {
            var content = 'bugDetail.html?bugId=';

            var title = "BUG-" + $(this).attr('statusText');
            index = layer.open({
                type: 2,
                title: title,
                skin: 'ilayui-layer-rm', //加上边框
                area: ['90%', '90%'], //宽高
                content: content + $(this).parent('tr').attr('id'),
//                end: function () {
//                    location.reload();
//                }
            });
        });
    });

    function clearForms() {
        $('#createName').val("");
        $('#demandProduct').val("0");
        $('#status').val("0");
        $('#programmer').val("");
        $("#status").multipleSelect("refresh");
        $('#title').val("0");
        $("#title").multipleSelect("refresh");
        $('#beginTime').val("");
        $('#detail').val("");
        $('#endTime').val("");
        $('#joinName').val("");
        $('#currentPrincipal').val("");
        $('#isSuspend').val("0");
        $('#priority').val("0");
        $('#feedbackName').val("");
        $('#feedbackCity').val("");
        $('#finishEndTime').val("");
        $('#finishBeginTime').val("");
        $('#demId').val("");
    }

    $("#subBtn").click(function () {
        window.location = "goAddDemandSource.html";
    });


</script>
</html>
